<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateProductPropertiesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        /**
         *   `id` int(11) NOT NULL AUTO_INCREMENT,
        `name` varchar(30) DEFAULT '' COMMENT '详情属性名称',
        `detail` varchar(255) NOT NULL COMMENT '详情属性',
        `product_id` int(11) NOT NULL COMMENT '商品id，外键',
        `delete_time` int(11) DEFAULT NULL,
        `update_time` int(11) DEFAULT NULL,
         */
        Schema::create('product_properties', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->string('detail');
            $table->integer('product_id')->unsigned();
            $table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('product_properties');
    }
}
